package com.ymatou.iapi.accounting.service;

import java.util.ArrayList;

import org.json.JSONException;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.ymatou.iapi.accounting.parameter.UserAccountBalance;
import com.ymt.base.YmatouBaseCall;
import com.ymttest.utils.EnvSetup;
/**
*批量查询用户余额Call
*FreeMaker Template自动生成代码
*/
public class GetUserAccountBalanceListCall extends YmatouBaseCall{
	private static String opurl ="api/Account/GetUserAccountBalanceList";
	
	public GetUserAccountBalanceListCall() {
		super(EnvSetup.getSystemUrl("accounting_iapi"),opurl,"POST","JSON");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}
	public ArrayList<UserAccountBalance> getUserAccountBalanceList() throws JSONException{
		ArrayList<UserAccountBalance> list = new ArrayList<UserAccountBalance>();		
		String userAccountBalancelist =this.getJsonObject().get("Data").getAsJsonObject().getAsJsonArray("UserAccountBalanceList").toString();
		if (userAccountBalancelist!=null){			
			Gson gson = new Gson();
			list = gson.fromJson(userAccountBalancelist, new TypeToken<ArrayList<UserAccountBalance>>() {
			}.getType());
		}
		return list;
	}	
}